﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>test2.html</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="upload/js/jquery-1.7.2.min.js"></script>
        <script type="text/javascript">
		var b = function(){
			$("body").append("<div id='hid' style='background:red;position:absolute;width:880;height:120'>我是可以拖动的半透明div，Firefox下暂时只能获取点击事件，event无解</div>");
			$("#hid").fadeTo("slow", 0.5);
			$("#hid").mousedown(function(event){
				var offset=$("#hid").offset();
				x1=event.clientX-offset.left;
				y1=event.clientY-offset.top;
				$("#hid").mousemove(function(event){
				   $("#hid").css("left",(event.clientX-x1)+"px");
					$("#hid").css("top",(event.clientY-y1)+"px");
				});
				$("#hid").mouseup(function(event){
					$("#hid").unbind("mousemove");
				});
			});
		}
		$(document).ready(function(){
			$("#hid").mousedown(function(event){
				var offset=$(this).offset();
				x1=event.clientX-offset.left;
				y1=event.clientY-offset.top;
				$(this).mousemove(function(event){
				   	$(this).css("left",(event.clientX-x1)+"px");
					$(this).css("top",(event.clientY-y1)+"px");
				});
				$(this).mouseup(function(event){
					$(this).unbind("mousemove");
				});
			});
		});
		</script>
    </head>
    <body>
        <input type=button value="点我显示div" onclick="b()">
        <div id='hid' style="background:red;position:absolute;width:80px;height:50px;">content</div>
    </body>
</html>